dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.54])
AC_INIT([FSharpBinding], [0.1], [fsharpbinding@yahoo.com.au])
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE

MONODEVELOP_CSFLAGS=

SHAMROCK_EXPAND_LIBDIR
SHAMROCK_EXPAND_BINDIR
SHAMROCK_EXPAND_DATADIR

AC_PROG_INSTALL

AC_PATH_PROG(GMCS, gmcs, no)
if test "x$GMCS" = "xno"; then
        AC_MSG_ERROR([gmcs Not found])
fi

AC_PATH_TOOL([MDTOOL], [mdtool])

AC_ARG_ENABLE(debug,
	AC_HELP_STRING([--enable-debug],
		[Use 'DEBUG' Configuration [default=YES]]),
		enable_debug=yes, enable_debug=no)
AM_CONDITIONAL(ENABLE_DEBUG, test x$enable_debug = xyes)
if test "x$enable_debug" = "xyes" ; then
	CONFIG_REQUESTED="yes"
fi
AC_ARG_ENABLE(release,
	AC_HELP_STRING([--enable-release],
		[Use 'RELEASE' Configuration [default=NO]]),
		enable_release=yes, enable_release=no)
AM_CONDITIONAL(ENABLE_RELEASE, test x$enable_release = xyes)
if test "x$enable_release" = "xyes" ; then
	CONFIG_REQUESTED="yes"
fi
if test -z "$CONFIG_REQUESTED" ; then
	AM_CONDITIONAL(ENABLE_DEBUG, true)
	enable_debug=yes
fi


dnl package checks, common for all configs
PKG_CHECK_MODULES([GTK_SHARP_20], [gtk-sharp-2.0])
PKG_CHECK_MODULES([MONODEVELOP], [monodevelop >= 1.9])
PKG_CHECK_MODULES([MONO_ADDINS], [mono-addins])

MONODEVELOP_VERSION=`$PKG_CONFIG --modversion monodevelop`
if test "x$MONODEVELOP_VERSION" == "x1.9" ; then
	MONODEVELOP_VERSION=1.9.0
fi

PKG_CHECK_EXISTS([monodevelop >= 2.2], [have_md_22=yes], [have_md_22=no])
if test "x$have_md_22" == "xyes" ; then
	MONODEVELOP_CSFLAGS=-define:MONODEVELOP_2_2,MONODEVELOP_2_1,MONODEVELOP_2_0,MONODEVELOP_1_9_1
else
PKG_CHECK_EXISTS([monodevelop >= 2.1], [have_md_21=yes], [have_md_21=no])
if test "x$have_md_21" == "xyes" ; then
	MONODEVELOP_CSFLAGS=-define:MONODEVELOP_2_1,MONODEVELOP_2_0,MONODEVELOP_1_9_1
else
PKG_CHECK_EXISTS([monodevelop >= 2.0], [have_md_20=yes], [have_md_20=no])
if test "x$have_md_20" == "xyes" ; then
	MONODEVELOP_CSFLAGS=-define:MONODEVELOP_2_0,MONODEVELOP_1_9_1
else
PKG_CHECK_EXISTS([monodevelop >= 1.9.1], [have_md_191=yes], [have_md_191=no])
if test "x$have_md_191" == "xyes" ; then
	MONODEVELOP_CSFLAGS=-define:MONODEVELOP_1_9_1
fi
fi
fi
fi

ADDIN_ID=MD_${MONODEVELOP_VERSION}_FSharpBinding
ADDIN_NAME=MonoDevelop.${ADDIN_ID}_${PACKAGE_VERSION}

AC_SUBST(ADDIN_ID)
AC_SUBST(ADDIN_NAME)
AC_SUBST(MONODEVELOP_CSFLAGS)
AC_SUBST(MONODEVELOP_VERSION)

AC_CONFIG_FILES([
Makefile
FSharpBinding.addin.xml
])

AC_OUTPUT
